import { ObjCreate } from "../common/ObjCreate";
import { GangFightsResultCellRenderer } from "./cellRenderer/GangFightsResultCellRenderer";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { GTileList } from "../../../../com/mui/controls/GTileList";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { GangFightsResultTeamData } from "./data/GangFightsResultTeamData";
import { ObjTeamCreate } from "../common/ObjTeamCreate";
import { Language } from "../../../../extend/language/Language";
import { EntityUtil } from "../../scene/layer/utils/EntityUtil";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { GameDefConfig } from "../../resource/GameDefConfig";
type int = number;
//class GangFightsGroupResult
    
    export  class GangFightsGroupResult /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.mouseChildren = false;
            this.mouseEnabled = false;
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createBg(0, 0, 804, 232, this);
            this._spGroup = new Object /* flash.display.Sprite */();
            this._spGroup.mouseChildren = false;
            this._spGroup.mouseEnabled = false;
            this.addChild(this._spGroup);
            this._tileList = ObjCreate.createTileList(224, 2, 667, 228, this);
            this._tileList.columnWidth = 667;
            this._tileList.rowHeight = 76;
            this._tileList.setStyle("cellRenderer", GangFightsResultCellRenderer);
            return;
        }

        public updateData(arg1: Array<any>, arg2: Array<any>): void
        {
            this._tileList.dataProvider = new DataProvider(arg2);
            this._tileList.drawNow();
            this.redrawGroupResult(arg1);
            return;
        }

        /* internal  */redrawGroupResult(arg1: Array<any>): void
        {
            var loc1=0;
            var loc3=null;
            var loc4=null;
            loc1 = (this._spGroup.numChildren - 1);
            while (loc1 >= 0) 
            {
                this._spGroup.removeChildAt(loc1);
                --loc1;
            }
            var loc2=0;
            loc1 = 0;
            while (loc1 < arg1.length) 
            {
                loc3 = arg1[loc1];
                (loc4 = new GroupCell()).x = 0;
                loc4.y = loc2 + (loc3.teamMemberNum - 1) * 38;
                loc4.updateData(loc3);
                this._spGroup.addChild(loc4);
                loc2 = loc2 + 76 * loc3.teamMemberNum;
                if (loc1 < (arg1.length - 1)) 
                {
                    ObjCreate.createBg(5, loc2, 780, 2, this._spGroup, "SplitLine");
                }
                ++loc1;
            }
            return;
        }

        /* internal */ /* var */_tileList: GTileList;

        /* internal */ /* var */_spGroup: Object /* flash.display.Sprite */;
    }
}


class GroupCell extends flash.display.Sprite
{
    public GroupCell()
    {
        super();
        this.mouseEnabled = false;
        this.mouseChildren = false;
        this.init();
        return;
    }

    /* internal  */init(): void
    {
        ObjCreate.createBg(11, 6, 64, 64, this);
        this._bmpFace = new Object /* flash.display.Bitmap */();
        this._bmpFace.x = 13;
        this._bmpFace.y = 8;
        this.addChild(this._bmpFace);
        this._tfTeamName = ObjCreate.createTextField("", 85, 7, 150, 20, this);
        this._tfServer = ObjCreate.createTextField("", 85, 29, 150, 20, this);
        this._tfScore = ObjCreate.createTextField("", 85, 51, 150, 20, this);
        LoaderHelp.addResCallBack(ResFileConst.GangFightsFace, this.onResCompl);
        return;
    }

    public updateData(arg1: GangFightsResultTeamData): void
    {
        this._resultTeamData = arg1;
        ObjTeamCreate.setTextFieldKeyValue(this._tfTeamName, Language.getString(44577), arg1.teamName);
        ObjTeamCreate.setTextFieldKeyValue(this._tfServer, Language.getString(44578), "[" + EntityUtil.getProxyName(arg1.entityId) + "]");
        ObjTeamCreate.setTextFieldKeyValue(this._tfScore, Language.getString(44579), arg1.teamMark + this.getAddMarkHtml(arg1.teamMarkAdd));
        this.updateFace();
        return;
    }

    /* internal  */onResCompl(): void
    {
        this._isResCompl = true;
        this.updateFace();
        return;
    }

    /* internal  */updateFace(): void
    {
        if (this._isResCompl && this._resultTeamData) 
        {
            this._bmpFace.bitmapData = GlobalClass.getBitmapData(GameDefConfig.instance.getGangFightsFaceName(this._resultTeamData.faceId));
        }
        return;
    }

    /* internal  */getAddMarkHtml(arg1: int): string
    {
        if (arg1 >= 0) 
        {
            return "<font color = \'#00FF00\'>(+" + arg1 + ")</font>";
        }
        return "<font color = \'#ff5b5b\'>(-" + Math.abs(arg1) + ")</font>";
    }

    /* internal */ /* var */_tfTeamName: Object /* flash.text.TextField */;

    /* internal */ /* var */_tfServer: Object /* flash.text.TextField */;

    /* internal */ /* var */_tfScore: Object /* flash.text.TextField */;

    /* internal */ /* var */_bmpFace: Object /* flash.display.Bitmap */;

    /* internal */ /* var */_resultTeamData: GangFightsResultTeamData;

    /* internal */ /* var */_isResCompl: Boolean=false;
